package com.jubotech.business.web.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jubotech.business.web.dao.WxForwardDao;
import com.jubotech.business.web.domain.ForwardLog;
import com.jubotech.business.web.domain.WxFriendaddLog;
import com.jubotech.business.web.domain.vo.ForwardLogStatVo;
import com.jubotech.business.web.query.ForwardLogQuery;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
@Transactional // 支持事务
public class WxForwardService {

	@Resource
	private WxForwardDao wxForwardDao;


	public WxFriendaddLog queryHaving(ForwardLog query){
		return wxForwardDao.queryHaving(query);
	}

	public int save(ForwardLog log){
		log.setCreate_time(new Date());
		return wxForwardDao.insert(log);
	}


	public PageInfo<ForwardLog> pageList(ForwardLogQuery query) {
		PageHelper.startPage(query.getPage(), query.getRows());
		return new PageInfo<>(wxForwardDao.pageList(query));
	}

	public List<ForwardLogStatVo> forwardStat(ForwardLogQuery forwardLogQuery) {
		return wxForwardDao.forwardStat(forwardLogQuery);
	}
}
